package com.theone.sample;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.theone.sample.annotation.OnClick;
import com.theone.sample.annotation.OnLongClick;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        InjectUtil.injectEvent(this);
    }

    @OnClick({R.id.button1,R.id.button2})
//    @OnClick(ids = {R.id.button1,R.id.button2})
    public void onClick(View view){
        showToast(view,"onClick");
    }

    @OnLongClick({R.id.button1,R.id.button2})
    public boolean onLongClick(View view){
        showToast(view,"onLongClick");
        return false;
    }

    @SuppressLint("ShowToast")
    private void showToast(View view, String type){
        Button btn = (Button) view;
        String title = btn.getText().toString();
        Toast.makeText(this,type+" : "+title,Toast.LENGTH_SHORT).show();
    }
}